var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
// var logger = require('morgan');

var indexRouter = require('./routes/index');
var usersRouter = require('./routes/users');

var app = express();

// app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use("/uploads",express.static(path.join(__dirname, 'uploads'))); 

app.use('/v1', indexRouter);
app.use('/users', usersRouter);

//404错误中间件
app.use((req,res)=>{
    res.json({code:404,data:null,msg:"请求与接口不匹配"})
})
module.exports = app;
